﻿using DTO;
using IBll;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model;

namespace ApiDay9_l.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class SroresController : ControllerBase, ISroreBll
    {
        public SroresController(ISroreBll bll) 
        {
            Bll = bll;
        }

        public ISroreBll Bll { get; }

        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="srore">门店表</param>
        /// <returns>返回受影响行数</returns>
        [HttpPost("AddSrore")]
        public async Task<int> AddSrore(Srore srore)
        {
            return await Bll.AddSrore(srore);
        }

        /// <summary>
        /// 显示+分页+查询
        /// </summary>
        /// <param name="pageindex">当前页</param>
        /// <param name="pagesize">每页显示条数</param>
        /// <param name="name">门店名称</param>
        /// <param name="time">创建日期</param>
        /// <returns></returns>
        [HttpGet("ShowSrore")]
        public SroreDto ShowSrore(int pageindex, int pagesize, string? name, DateTime? time)
        {
            return Bll.ShowSrore(pageindex, pagesize, name, time);
        }

        /// <summary>
        /// 删除
        /// 逻辑
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns>根据主键返回门店表</returns>
        [HttpGet("IDelete")]
        public async Task<int> IDelete(int id)
        {
            return await Bll.IDelete(id);

        }

        /// <summary>
        /// 反填
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns>根据主键进行反填</returns>
        [HttpGet("Find")]
        public Srore Find(int id)
        {
            return Bll.Find(id);
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="srore">门店表</param>
        /// <returns>返回受影响行数</returns>
        [HttpPost("Update")]
        public async Task<int> Update(Srore srore)
        {
           return await Bll.Update(srore);
        }





    }
}
